<?php
namespace app\lnadmin\model;
use app\core\InitController;

use think\facade\Session;
use think\Model;

class Base extends Model
{
    // 获取左侧主菜单
    public static function getMenus($uid)
    {  
        $group = \app\lnadmin\model\admin\AuthGroup::findGroup($uid);
         // 读取管理员当前拥有的权限节点
        $user_id = explode(',',$group['rules']);
        $authRule = \app\lnadmin\model\admin\AuthRule::where(['ismenu' => 1, 'status' => 1])
            ->order('weigh asc')
            ->force('rules')
            ->whereIn('id',$user_id)
            ->field(['id','pid','url as href','name as title','icon','weigh','status','ismenu as type','openType'])
            ->select()
            ->toArray();  
          
           return list_to_tree($authRule);
    }

}